package utils
{
	public class ObjectTools extends Object
	{
		
		public function ObjectTools()
		{
			return;
		}// end function
		
		public static function getAssetByNameOrExceptionIfNull(param1:Object, param2:String) : Object
		{
			return _getAssetByNameOrExceptionIfNull(param1, param2);
		}// end function
		
		private static function _getPropertyValue(param1:Object, param2:String, param3:Object, param4:Boolean) : Object
		{
			var lValue_obj:Object;
			var aObject_obj:* = param1;
			var aPropertyName_str:* = param2;
			var aPropertyUndefinedValue_obj:* = param3;
			var aThrowIfUndefined_bl:* = param4;
			try
			{
				lValue_obj = aObject_obj[aPropertyName_str];
			}
			catch (aError_err:Error)
			{
				lValue_obj = undefined;
			}
			if (lValue_obj == undefined as Object)
			{
				if (aThrowIfUndefined_bl)
				{
					throw Error("Property \'" + aPropertyName_str + "\' is not defined in the object \'" + aObject_obj + "\'");
				}
				return aPropertyUndefinedValue_obj;
			}
			return lValue_obj;
		}// end function
		
		public static function getPropertyValue(param1:Object, param2:String, param3:Object = , param4:Boolean = false) : Object
		{
			return _getPropertyValue(param1, param2, param3, param4);
		}// end function
		
		private static function _getAssetByNameOrExceptionIfNull(param1:Object, param2:String) : Object
		{
			var _loc_3:Object = null;
			_loc_3 = _getAssetByNameOrNull(param1, param2);
			if (!_loc_3)
			{
				throw Error("Object \'" + param1 + "\' has not asset \'" + param2 + "\'");
			}
			return _loc_3;
		}// end function
		
		private static function _getPropertyValueAsString(param1:Object, param2:String, param3:String, param4:Boolean) : String
		{
			return _getPropertyValue(param1, param2, param3, param4) as String;
		}// end function
		
		public static function getPropertyValueAsString(param1:Object, param2:String, param3:String = null, param4:Boolean = false) : String
		{
			return _getPropertyValueAsString(param1, param2, param3, param4);
		}// end function
		
		private static function _getAssetByName(param1:Object, param2:String, param3:Boolean) : Object
		{
			if (param3)
			{
				return _getAssetByNameOrExceptionIfNull(param1, param2);
			}
			return _getAssetByNameOrNull(param1, param2);
		}// end function
		
		public static function getAssetByName(param1:Object, param2:String, param3:Boolean) : Object
		{
			return _getAssetByName(param1, param2, param3);
		}// end function
		
		public static function getAssetByNameOrNull(param1:Object, param2:String) : Object
		{
			return _getAssetByNameOrNull(param1, param2);
		}// end function
		
		private static function _getAssetByNameOrNull(param1:Object, param2:String) : Object
		{
			var aObject_obj:* = param1;
			var aAssetName_str:* = param2;
			try
			{
				return aObject_obj[aAssetName_str];
			}
			catch (aError_err:Error)
			{
			}
			return null;
		}// end function
		
	}
}
